<?php

/**
 * Gere les exceptions levees par le package Bundle
 *
 * @category   McCube
 * @package    Db
 * @author     Leiha Sellier <leiha.sellier@gmail.com>
 * @license    http://creativecommons.org/licenses/by/3.0/  CC BY 3.0
 * @link       http://code.google.com/p/mechanics-cubes/
 */
class McCube_Db_Exception
     extends McCube_Exception{

    protected $_title = 'Exception Database';
    protected $_richTitle = '[@error@Exception Database@]';

    public function __construct($message, $errorCode, $extras=array()){
        parent::__construct($message, 0, $extras);
        $this->errorCode = $errorCode;
        $this->_extraDatas = $extras;
        $this->buildRealMessage();
    }

    public function buildRealMessage(){
        switch($this->message){
            default : $txt = $this->message; break;
        }

        $this->message = $txt;
        if(isset($this->_extraDatas['query']))
            $this->message .= "\n".' - Query [ '.
            '[@bundle@'.$this->_extraDatas['query'].'@]'
        .' ]';
    }
}